package chis.fx.stage;

import javafx.beans.binding.SetExpression;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class FlowPaneStage extends Stage {

	private FlowPane root;
	private Scene scene;

	private int myStageWidth = 800;
	private int myStageHeight = 600;

	public FlowPaneStage() {
		root = new FlowPane();
		scene = new Scene(root, 800, 600, Color.PINK);
		addCircles();
		this.setScene(scene);
	}
	

	public void addCircles() {
		
		int numberOfCirclesAcross = 10;
		int circleWidth = (myStageWidth / numberOfCirclesAcross);
		int circleRadius = circleWidth / 2;
		int numberOfCirclesDown = myStageHeight / circleWidth;
		int numberOfCircles = numberOfCirclesAcross * numberOfCirclesDown;

		for (int x = 0; x < numberOfCircles; x ++) {
			
			final Circle circle = new Circle(circleRadius, Color.web("white", 0.5));
			circle.addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>(){
	               @Override
	               public void handle(MouseEvent event) {
	            	   circle.setFill(Color.web("white", 1));
	               }
	           });
			circle.addEventHandler(MouseEvent.MOUSE_EXITED, new EventHandler<MouseEvent>(){
	               @Override
	               public void handle(MouseEvent event) {
	            	   circle.setFill(Color.web("pink", 0.5));
	               }
	           });
			
			root.getChildren().add(circle);

		}

	}

}
